package com.test.io;

import java.util.prefs.Preferences;

public class PreferenceDemo {

	public static void main(String[] args) throws Exception {
		Preferences prefs = Preferences
				.userNodeForPackage(PreferenceDemo.class);
		prefs.put("Location", "Oz");
		prefs.put("FootWear", "Ruby Slippers");
		prefs.putInt("Companion", 4);
		prefs.putBoolean("Are there witches", true);
		int usageCount = prefs.getInt("UsageCount", 0);
		usageCount++;
		prefs.putInt("UsageCount", usageCount);
		for (String key : prefs.keys()) {
			System.out.println(key + ": " + prefs.get(key, null));

		}
		System.out.println("How many companions does dorothy have? "
				+ prefs.getInt("Companion", 0));
	}
}
